/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.cibertec.dawii.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Manuel Eguiluz
 */
@Entity
@Table(name = "staff_skill", catalog = "uservoice", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StaffSkill.findAll", query = "SELECT s FROM StaffSkill s"),
    @NamedQuery(name = "StaffSkill.findBySkillCode", query = "SELECT s FROM StaffSkill s WHERE s.staffSkillPK.skillCode = :skillCode"),
    @NamedQuery(name = "StaffSkill.findBySupportStaff", query = "SELECT s FROM StaffSkill s WHERE s.staffSkillPK.supportStaff = :supportStaff"),
    @NamedQuery(name = "StaffSkill.findByDateSkillObtained", query = "SELECT s FROM StaffSkill s WHERE s.dateSkillObtained = :dateSkillObtained")})
public class StaffSkill implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected StaffSkillPK staffSkillPK;
    @Basic(optional = false)
    @Column(name = "date_skill_obtained", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateSkillObtained;
    @JoinColumn(name = "support_staff", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private SupportStaff supportStaff1;
    @JoinColumn(name = "skill_code", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private SkillCode skillCode1;

    public StaffSkill() {
    }

    public StaffSkill(StaffSkillPK staffSkillPK) {
        this.staffSkillPK = staffSkillPK;
    }

    public StaffSkill(StaffSkillPK staffSkillPK, Date dateSkillObtained) {
        this.staffSkillPK = staffSkillPK;
        this.dateSkillObtained = dateSkillObtained;
    }

    public StaffSkill(int skillCode, int supportStaff) {
        this.staffSkillPK = new StaffSkillPK(skillCode, supportStaff);
    }

    public StaffSkillPK getStaffSkillPK() {
        return staffSkillPK;
    }

    public void setStaffSkillPK(StaffSkillPK staffSkillPK) {
        this.staffSkillPK = staffSkillPK;
    }

    public Date getDateSkillObtained() {
        return dateSkillObtained;
    }

    public void setDateSkillObtained(Date dateSkillObtained) {
        this.dateSkillObtained = dateSkillObtained;
    }

    public SupportStaff getSupportStaff1() {
        return supportStaff1;
    }

    public void setSupportStaff1(SupportStaff supportStaff1) {
        this.supportStaff1 = supportStaff1;
    }

    public SkillCode getSkillCode1() {
        return skillCode1;
    }

    public void setSkillCode1(SkillCode skillCode1) {
        this.skillCode1 = skillCode1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (staffSkillPK != null ? staffSkillPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StaffSkill)) {
            return false;
        }
        StaffSkill other = (StaffSkill) object;
        if ((this.staffSkillPK == null && other.staffSkillPK != null) || (this.staffSkillPK != null && !this.staffSkillPK.equals(other.staffSkillPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.cibertec.dawii.entity.StaffSkill[ staffSkillPK=" + staffSkillPK + " ]";
    }
    
}
